package com.lovo.register;

import java.util.Scanner;

public class Register {
    public static void main(String[] args) {
        Register r = new Register();
        r.register();
    }

    public void register(){
        System.out.println("欢迎您！");
        Scanner sc = new Scanner(System.in);
        while (true) {
            System.out.println("请输入用户名：");
            String userID = sc.next();
            if (userID.matches("^[\\w]{6,20}$")) {
                System.out.println("请输入密码：");
                String userpwd = sc.next();
                if (userpwd.matches("^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z])[a-zA-Z0-9]{6,}$")){
                    System.out.println("请再次确认密码：");
                    String userpwd1 = sc.next();
                    if (userpwd.equals(userpwd1)){
                        System.out.println("请输入邮箱：");
                        String usermail = sc.next();
                        if (usermail.matches("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$")){
                            System.out.println("注册成功");
                            break;
                        } else {
                            System.out.println("邮箱格式不匹配，请重新输入");
                        }
                    } else {
                        System.out.println("与第一次密码不匹配，请重新输入");
                    }
                } else {
                    System.out.println("密码格式不匹配，请重新输入");
                }
            } else {
                System.out.println("用户名格式不匹配，请重新输入");
            }
        }
    }
}
